home *** CD-ROM | disk | FTP | other *** search
/ PC Shareware 1997 February / PC Shareware 1997-02.iso / programy / e! / technote / ewtech.$10 / ewtech.010
Encoding:
Text File  |  1995-03-05  |  7.0 KB  |  218 lines

  1. E! for Windows - Technical Note #010
  2. **********************************************************
  3. Syntax Highlighting Description Files (.HDF) - File Format
  4. **********************************************************
  5.  
  6. You can easily create a syntax highlighting description file for
  7. almost any programming language or script language. You just have to
  8. inform E! about how comments are defined in this language, whether
  9. the language is case sensitive, what are the string delimiters and
  10. token delimiters and also provide a list of the language keywords.
  11. Examining existing HDF files will give you a good idea of how to
  12. setup your own HDF files.
  13.  
  14. Here is a reference to all statements that you can add to an HDF
  15. file.
  16.  
  17. 1. HDF Comments
  18. ***************
  19.  
  20. Any line of an HDF file beginning with a semicolon as the first non
  21. blank character will be considered as a comment and discarded.
  22.  
  23. 2. CASE statement
  24. *****************
  25.  
  26. CASE appearing on any line of the HDF file means that the language is
  27. case sensitive. No additional parameters are needed. Languages that
  28. are not case sensitive don't need any declaration. This is the
  29. default.
  30.  
  31. 3. Comment Definition
  32. *********************
  33.  
  34. There are three ways to define comments:
  35.  
  36. COMMENT  <opening_sequence> <closing_sequence>
  37.  
  38.      ex: COMMENT /* */
  39.  
  40. COMMENT  <opening_sequence>
  41.  
  42.      ex: COMMENT //
  43.      In that case, the closing sequence is always an End Of Line.
  44.  
  45. COMMENTFIRST <opening_sequence>
  46.  
  47.      ex: COMMENTFIRST *
  48.      This means that the opening sequence must be the first non
  49.      blank character on the line to be considered as a comment
  50.      opening. The closing sequence is also an End Of Line.
  51.  
  52. You can add multiple COMMENT statements to an HDF file.
  53.  
  54.  
  55. 4. CONST Statement
  56. ******************
  57.  
  58. This statement defines a regular expression describing how numeric
  59. constants can appear in your source code. The syntax used for regular
  60. expression is the one explained in the EW documentation.
  61.  
  62.  
  63. CONST  <regular_expression>
  64.  
  65.        ex: CONST [0-9]#
  66.  
  67. You can add up to 10 CONST statements to an HDF file. Be cautious
  68. about the order of declaration because, for some languages, priority
  69. may have an influence on the way tokens are parsed. In an HDF file,
  70. the first declared CONST statement has a higher priority as the next
  71. one and so on...
  72.  
  73.  
  74. 5. STRINGDELIMITER statement
  75. ****************************
  76.  
  77. You can declare only one character that will be considered as a
  78. string delimiter for your language. It is assumed that the same
  79. character is used to close the string. If the STRINGDELIMITER can
  80. appear within a string, you have to define an ESCAPE character.
  81.  
  82. STRINGDELIMITER  <char>
  83.  
  84.          ex: STRINGDELIMITER "
  85.  
  86. 6. ESCAPECHAR statement
  87. ***********************
  88.  
  89. This statement is used to define how string delimiters can be
  90. "escaped" within a string. You can define only one ESCAPECHAR.
  91.  
  92. ESCAPECHAR <char>
  93.  
  94.        ex: ESCAPECHAR \
  95.  
  96. 7. COMMENTESCAPECHAR statement
  97. ******************************
  98.  
  99. This statement is used to allow tokens normally used as comment
  100. opening sequences to be freely used in the text without defining
  101. a comment. This function is *not* necessary with standard languages
  102. but source files like TeX source files will need it. For example,
  103. TeX source lines like this one
  104.  
  105. $>$, $<$, \%, \$, $\ast$, $+$, @, \#, \_, \{, \} ?
  106.        ^---------- comment -------------------
  107.  
  108. will generate a problem because the % will trigger a single
  109. line comment. If you define \ as a COMMENTESCAPECHAR, % will
  110. be ignored when scanning for comments.
  111.  
  112. You can define only one COMMENTESCAPECHAR.
  113.  
  114. COMMENTESCAPECHAR <char>
  115.  
  116.        ex: COMMENTESCAPECHAR \
  117.  
  118.  
  119. 8. TOKENDELIMITERS statement
  120. ****************************
  121.  
  122. This statement defines which characters are used to separate tokens.
  123. The StringDelimiter can be (should be) included in the Token
  124. Delimiters.
  125.  
  126. TOKENDELIMITERS  <string_made_up_of_delimiters>
  127.  
  128.          ex: TOKENDELIMITERS ",;:*{}[]<>()=/+-#^
  129.  
  130.  
  131. 9. SPECIALDELIMITERS statement
  132. ******************************
  133.  
  134. For certain languages, it may happen that Token Delimiters also appear
  135. in tokens themselves. This is especially true for TeX source files. This
  136. statement allows you to declare which Token Delimiters may also appear
  137. in a token. Declaring one or more Special Delimiters triggers a special
  138. processing when E! scans your source code. Be aware that doing so will
  139. slow down the text display a little.
  140.  
  141. This feature is normally not needed for standard languages.
  142.  
  143. SPECIALDELIMITERS  <string_made_up_of_delimiters>
  144.  
  145.            ex: SPECIALDELIMITERS \
  146.  
  147. 10. FORCEDTOKEN statement
  148. ************************
  149.  
  150. This statement allows to define substrings that will be highlighted
  151. even if they can't be considered as tokens. Usually, such substrings
  152. will be defined as regular expressions.
  153.  
  154. This feature is provided for special needs (TeX) but will cause the
  155. display to be *significantly* slower if you use more than one or two
  156. FORCEDTOKEN statements.
  157.  
  158. You can add up to 25 FORCEDTOKEN statements to an HDF file.
  159.  
  160. FORCEDTOKEN  <regular_expression>
  161.  
  162.          FORCEDTOKEN \{[^{}]@\}
  163.  
  164. This example tells E! to highlight any {string} sequence in a TeX
  165. source file, for example. Coloring of selected areas and comments
  166. has priority over this definition which has itself priority over any
  167. other token.
  168.  
  169.  
  170. 11. KEYWORD, FUNCTION, USERFUNCx statements.
  171. *******************************************
  172.  
  173. These statements have no formal meaning regarding the language.
  174. Each of them is assigned a different color. Normally, the KEYWORD
  175. statement will declare the actual language keywords and the FUNCTION
  176. statement will declare standard functions. USERFUNCx statements will
  177. be used for different types of keywords depending on your needs and
  178. on the language.
  179.  
  180. KEYWORD <keyword>
  181.  
  182.     ex: KEYWORD if
  183.  
  184. FUNCTION <function>
  185.  
  186.     ex: FUNCTION strlen
  187.  
  188. USERFUNC1 <myfunc>
  189.  
  190.     ex: USERFUNC1 my_own_strlen
  191.  
  192.  
  193. There is absolutely no difference in the way these different
  194. statements are processed except that they are stored in the
  195. dictionnary with different color assignements. So, you may use them
  196. as you want. For example, we provide a WIN.HDF file which declares
  197. all Windows messages. You can add it to any section of an HDF file
  198. to have all Windows messages highlighted in your source files.
  199. Please see the provided HDF files for an example of different uses
  200. of these statements.
  201.  
  202. When E! loads a file, it generates a dictionary from the
  203. corresponding HDF file. This dictionary is used by all files having
  204. a filename extension associated with this HDF file. Space is provided
  205. for 1024 tokens. You can add more tokens to your HDF file but this
  206. will slow down the display a little if you add, say, 1500 or 2000
  207. definitons to an HDF file. This will also use more memory space.
  208.  
  209. The use of HDF files is not limited to languages. For example, you
  210. could use HDF files to generate syntax highlighting for .BAT files:
  211. DOS internal commands would be assigned a different color than the
  212. DOS external commands. Another interesting use would be to have an
  213. HDF file for your communication software script language.
  214.  
  215.  
  216. Patrick Philippot
  217. 05/15/94
  218.